﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace YAPL.Language.Ast {
	public class ConstantExpression : Expression {
		private readonly object _value;
		public ConstantExpression(ExpressionType nodeType, Type type, object value) : base(nodeType, type, false, false) {
			_value = value;
		}
		public object Value {
			get { return _value; }
		}

		public override bool NodeEquals(Expression other) {
			if (other is ConstantExpression) {
				if (_value == null) {
					if ((other as ConstantExpression)._value == null) return true;
					return false;
				}
				return _value.Equals((other as ConstantExpression)._value);
			}
			return false;
		}

		public override bool RewriteChild(Expression child, Expression newExpression) {
			return false;
		}
	}
}
